home *** CD-ROM | disk | FTP | other *** search
/ E.M.Computergraphic Phase 4 / Phase 4 - Desktop Video Dreams (E. M. Computergraphic)(1996).iso / utilities / multiplay / gmod / dw_convert.c < prev    next >
C/C++ Source or Header  |  1996-01-03  |  1KB  |  52 lines

  1. /* DW_Convert.c */
  2.  
  3. /* This short C program takes a Dave Whittaker module as an input file, and
  4. writes it out as a GMOD module.  This is not incredibly useful, since
  5. MultiPlayer and many other player programs can play Dave Whittaker modules
  6. without any help.  However, it illustrates how you can add GMOD support to
  7. music composer programs and such.  */
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11.  
  12. /* These labels are defined in DW_GMOD.asm */
  13. extern char HeaderBegin[], HeaderEnd[];
  14.  
  15. FILE *infh, *outfh;
  16.  
  17. char copybuf[8192];
  18.  
  19. int gotsize;
  20.  
  21. void die(char *mes)
  22.   {
  23.     puts(mes);
  24.     exit(10);
  25.   }
  26.  
  27. void main(int argc,char **argv)
  28.   {
  29.     if(argc != 3)
  30.       die("Usage: DW_Convert <infile> <outfile>\n");
  31.  
  32.     if(!(infh = fopen(argv[1],"r")))
  33.       die("Can't open input file");
  34.  
  35.     if(!(outfh = fopen(argv[2],"w")))
  36.       die("Can't open output file");
  37.  
  38.     /* First write the DW_GMOD header */
  39.     if(fwrite(HeaderBegin,1,(long)(HeaderEnd-HeaderBegin),outfh) <= 0)
  40.       die("Error writing GMOD header");
  41.  
  42.     /* Then just copy everything else over */
  43.     while((gotsize = fread(copybuf,1,8192,infh)) > 0)
  44.       if(fwrite(copybuf,1,gotsize,outfh) <= 0)
  45.         die("Error copying to output file");
  46.     if(gotsize < 0)
  47.       die("Error reading from input file");
  48.  
  49.     /* Let the startup code close our files (I'm lazy I know) */
  50.   }
  51.  
  52.